package org.tacademy.homework3;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.LinearLayout;

public class SlidingPageActivity extends Activity {
	Animation downAnim;
	Animation rightAnim;
	Animation upAnim;
	Animation leftAnim;
	LinearLayout layout01;
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.pageslide);
		
		downAnim = AnimationUtils.loadAnimation(this, R.anim.flowdown);
		upAnim = AnimationUtils.loadAnimation(this, R.anim.flowup);
		rightAnim = AnimationUtils.loadAnimation(this, R.anim.flowright);
		leftAnim = AnimationUtils.loadAnimation(this, R.anim.flowleft);
		
		layout01 = (LinearLayout)findViewById(R.id.layout);
		Button downBtn = (Button)findViewById(R.id.downBtn);
		Button rightBtn = (Button)findViewById(R.id.rightBtn);
		
		downBtn.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				layout01.startAnimation(downAnim);
				downAnim.setAnimationListener(new AnimationListener() {
					
					public void onAnimationStart(Animation animation) {
						
					}
					
					public void onAnimationRepeat(Animation animation) {
						
					}
					
					public void onAnimationEnd(Animation animation) {
						layout01.startAnimation(upAnim);
					}
				});
			}
		});
		
		rightBtn.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				layout01.startAnimation(rightAnim);
				rightAnim.setAnimationListener(new AnimationListener() {
					
					public void onAnimationStart(Animation animation) {
						
					}
					
					public void onAnimationRepeat(Animation animation) {
						
					}
					
					public void onAnimationEnd(Animation animation) {
						layout01.startAnimation(leftAnim);
					}
				});
			}
		});
	}
	
	
}
